version 8.0
log using boix.log, replace
#delimit ;

*     ***************************************************************** *;
*     ***************************************************************** *;
*       File-Name:      boix.do                                         *;
*       Date:           11/14/04                                        *;
*       Author:         MRG                                             *;
*       Purpose:        Replicate Boix 1999                             *;
*       Input File:     boix.dta                                        *;
*       Output File:    boix.log                                        *;
*       Data Output:    none                                            *;
*       Previous file:                                                  *;
*       Machine:                                                        *;
*     ****************************************************************  *;
*     ****************************************************************  *;

set mem 10m;

use h:\politicalanalysis\replications\boix\boix.dta;



*     ****************************************************************  *;
*     ****************************************************************  *;
*     ****************************************************************  *;
*       Replicate results in Table 1                                    *;
*     ****************************************************************  *;
*     ****************************************************************  *;
*     ****************************************************************  *;


*     ****************************************************************  *;
*       Model 1                                                         *;
*     ****************************************************************  *;

regress threshold threat area trade population ethnic if interwar==1;

*     ****************************************************************  *;
*       Model 2                                                         *;
*     ****************************************************************  *;

regress threshold threat socialism parties area if interwar==1;

*     ****************************************************************  *;
*       Model 3                                                         *;
*     ****************************************************************  *;

gen area1=10^area;

gen areadummy=.;

replace areadummy=0 if area1>=450;

replace areadummy=1 if area1<450;

gen ethnic_dummy = ethnic*areadummy; 

regress threshold threat ethnic_dummy if interwar==1;

*     ****************************************************************  *;
*     ****************************************************************  *;
*     ****************************************************************  *;
*       Models 1, 2 and 3 when fully specified                          *;
*     ****************************************************************  *;
*     ****************************************************************  *;
*     ****************************************************************  *;

*     ****************************************************************  *;
*       Model 1                                                         *;
*     ****************************************************************  *;

regress threshold threat socialism parties area trade population ethnic if interwar==1;

*     ****************************************************************  *;
*       Model 2 is already fully-specified                              *;
*     ****************************************************************  *;

*     ****************************************************************  *;
*       Model 3                                                         *;
*     ****************************************************************  *;

regress threshold threat socialism parties ethnic areadummy ethnic_dummy if interwar==1;


*     ****************************************************************  *;
*       Does ethnic fragmentation ever have a significant effect?       *;
*     ****************************************************************  *;

regress threshold ethnic areadummy ethnic_dummy threat socialism parties if interwar==1;

matrix b=e(b);
matrix V=e(V);
scalar b1=b[1,1];
scalar b2=b[1,2];
scalar b3=b[1,3];

scalar varb1=V[1,1];
scalar varb2=V[2,2];
scalar varb3=V[3,3];
scalar covb1b3=V[1,3];
scalar covb2b3=V[2,3];

gen conb1=b1+b3*1;

display conb1;

gen conse1=sqrt(varb1+varb3*1^2+2*covb1b3*1);

display conse1;

*     ****************************************************************  *;
*       Does ethnic fragmentation ever have a significant effect? NO    *;
*     ****************************************************************  *;

drop conb1 conse1;

*     ****************************************************************  *;
*       Test footnote 34                                                *;
*     ****************************************************************  *;

regress threshold threat area trade population ethnic if interwar==1;

test area trade;

*     ****************************************************************  *;
*       Marginal effect of Socialism                                    *;
*     ****************************************************************  *;

set obs 70;

gen threat1=socialism*parties;

regress threshold  socialism parties threat1 area trade population ethnic if interwar==1;


generate JH=((_n-1)/10);    

replace JH=. if _n>60;

*     ****************************************************************  *;
*       Grab elements of the matrix required for calculating            *;
*       conditional coefficients and standard errors.                   *;
*     ****************************************************************  *;

matrix b=e(b);
matrix V=e(V);
scalar b1=b[1,1];
scalar b2=b[1,2];
scalar b3=b[1,3];

scalar varb1=V[1,1];
scalar varb2=V[2,2];
scalar varb3=V[3,3];
scalar covb1b3=V[1,3];
scalar covb2b3=V[2,3];


set more off;

scalar list b1 b2 b3 varb1 varb2 varb3 covb1b3 covb2b3;

*     ****************************************************************  *;
*         Create full range of conditional coefficients for proximity   *;
*     ****************************************************************  *;

gen conb=b1+b3*JH if _n<60;

set more off;

list conb in 1/20;

*     ****************************************************************  *;
*           Create full range of conditional standard errors            *;
*     ****************************************************************  *;

gen conse=sqrt(varb1+varb3*JH^2+2*covb1b3*JH)  if _n<60;
set more off;

*     ****************************************************************  *;
*               Generate confidence intervals at the 95% level          *;
*     ****************************************************************  *;
*     ****************************************************************  *;

gen a=2.074*conse;
gen top=conb+a;
gen bottom=conb-a;
set textsize 100;

*     ****************************************************************  *;
*       Graph the effect of socialism on electoral thresholds           *;
*     ****************************************************************  *;

graph twoway   line conb JH, clwidth(medium) clcolor(blue) clcolor(black)
        ||  line top  JH, clpattern(dash) clwidth(thin) clcolor(black)
        ||  line bottom JH, clpattern(dash) clwidth(thin) clcolor(black)
        ||  ,   
            xlabel(0 1 2 3 4 5 6, labsize(2.5)) 
            ylabel(-1.5 -1 -0.5 0 0.5 1 1.5 2 2.5, labsize(2.5))
            yscale(noline)
            xscale(noline)
            legend(col(1) order(1 2) label(1 "Marginal Effect of Socialist Strength") label(2 "95% Confidence Interval") 
                  label(3 " "))
        yline(0, lcolor(black))  
            title("Marginal Effect of Socialist Strength", size(4))
            subtitle(" " "Dependent Variable: Effective Electoral Threshold" " ", size(3))
            xtitle(Effective Number of Old Parties, size(3)  )
        xsca(titlegap(2))
        ysca(titlegap(2))
            ytitle("Marginal Effect of Socialist Strength", size(3))
        scheme(s2mono) graphregion(fcolor(white));
        
translate @Graph h:\politicalanalysis\replications\boix\socialism.eps;

*     ****************************************************************  *;
*       Marginal Effect of Non-Socialist Parties                        *;
*     ****************************************************************  *;

clear;

use h:\politicalanalysis\replications\boix\boix.dta;

set obs 600;

gen threat1=socialism*parties;

regress threshold  parties socialism threat1 area trade population ethnic if interwar==1;


generate JH=((_n-1)/10);    

replace JH=. if _n>550;

*     ****************************************************************  *;
*       Grab elements of the matrix required for calculating            *;
*       conditional coefficients and standard errors.                   *;
*     ****************************************************************  *;

matrix b=e(b);
matrix V=e(V);
scalar b1=b[1,1];
scalar b2=b[1,2];
scalar b3=b[1,3];

scalar varb1=V[1,1];
scalar varb2=V[2,2];
scalar varb3=V[3,3];
scalar covb1b3=V[1,3];
scalar covb2b3=V[2,3];


set more off;

scalar list b1 b2 b3 varb1 varb2 varb3 covb1b3 covb2b3;

*     ****************************************************************  *;
*         Create full range of conditional coefficients for proximity   *;
*     ****************************************************************  *;

gen conb=b1+b3*JH if _n<550;

set more off;

list conb in 1/20;

*     ****************************************************************  *;
*           Create full range of conditional standard errors            *;
*     ****************************************************************  *;

gen conse=sqrt(varb1+varb3*JH^2+2*covb1b3*JH)  if _n<550;
set more off;

*     ****************************************************************  *;
*               Generate confidence intervals at the 95% level          *;
*     ****************************************************************  *;
*     ****************************************************************  *;

gen a=2.074*conse;
gen top=conb+a;
gen bottom=conb-a;
set textsize 100;

*     ****************************************************************  *;
*       Graph the effect of non-socialist parties on electoral threshold*;
*     ****************************************************************  *;

graph twoway   line conb JH, clwidth(medium) clcolor(blue) clcolor(black)
        ||  line top  JH, clpattern(dash) clwidth(thin) clcolor(black)
        ||  line bottom JH, clpattern(dash) clwidth(thin) clcolor(black)
        ||  ,   
            xlabel(0 10 20 30 40 50 60, labsize(2.5)) 
            ylabel(-25 -20 -15 -10 -5 0 5 10 15 20 , labsize(2.5))
            yscale(noline)
            xscale(noline)
            legend(col(1) order(1 2) label(1 "Marginal Effect of Old Parties") label(2 "95% Confidence Interval") 
                  label(3 " "))
        yline(0, lcolor(black))  
            title("Marginal Effect of the Number of Non-Socialist Parties", size(4))
            subtitle(" " "Dependent Variable: Effective Electoral Threshold" " ", size(3))
            xtitle(Strength of Socialism, size(3)  )
        xsca(titlegap(2))
        ysca(titlegap(2))
            ytitle("Marginal Effect of Old Parties", size(3))
        scheme(s2mono) graphregion(fcolor(white));
        
translate @Graph h:\politicalanalysis\replications\boix\oldparties.eps;



*     ****************************************************************  *;
*       Now run some simulations to get predicted thresholds            *;
*     ****************************************************************  *;

estsimp regress threshold  parties socialism threat1 area trade population ethnic if interwar==1;

setx parties 2 area 3 trade mean population mean ethnic mean socialism 10 parties 2 threat1 20;

setx;

simqi;

drop b*;

estsimp regress threshold  parties socialism threat1 area trade population ethnic if interwar==1;

setx parties 2 area 3 trade mean population mean ethnic mean socialism 10 parties 4 threat1 40;

setx;

simqi;

drop b*;

estsimp regress threshold  parties socialism threat1 area trade population ethnic if interwar==1;

setx parties 2 area 3 trade mean population mean ethnic mean socialism 10 parties 6 threat1 60;

setx;

simqi;

drop b*;

estsimp regress threshold  parties socialism threat1 area trade population ethnic if interwar==1;

setx parties 2 area 3 trade mean population mean ethnic mean socialism 20 parties 2 threat1 40;

setx;

simqi;

drop b*;

estsimp regress threshold  parties socialism threat1 area trade population ethnic if interwar==1;

setx parties 2 area 3 trade mean population mean ethnic mean socialism 20 parties 4 threat1 80;

setx;

simqi;

drop b*;

estsimp regress threshold  parties socialism threat1 area trade population ethnic if interwar==1;

setx parties 2 area 3 trade mean population mean ethnic mean socialism 20 parties 6 threat1 120;

setx;

simqi;

drop b*;

estsimp regress threshold  parties socialism threat1 area trade population ethnic if interwar==1;

setx parties 2 area 3 trade mean population mean ethnic mean socialism 30 parties 2 threat1 60;

setx;

simqi;

drop b*;

estsimp regress threshold  parties socialism threat1 area trade population ethnic if interwar==1;

setx parties 2 area 3 trade mean population mean ethnic mean socialism 30 parties 4 threat1 120;

setx;

simqi;

drop b*;

estsimp regress threshold  parties socialism threat1 area trade population ethnic if interwar==1;

setx parties 2 area 3 trade mean population mean ethnic mean socialism 30 parties 6 threat1 180;

setx;

simqi;

drop b*;

estsimp regress threshold  parties socialism threat1 area trade population ethnic if interwar==1;

setx parties 2 area 3 trade mean population mean ethnic mean socialism 40 parties 2 threat1 80;

setx;

simqi;

drop b*;

estsimp regress threshold  parties socialism threat1 area trade population ethnic if interwar==1;

setx parties 2 area 3 trade mean population mean ethnic mean socialism 40 parties 4 threat1 160;

setx;

simqi;

drop b*;

estsimp regress threshold  parties socialism threat1 area trade population ethnic if interwar==1;

setx parties 2 area 3 trade mean population mean ethnic mean socialism 40 parties 6 threat1 240;

setx;

simqi;

drop b*;

*     ****************************************************************  *;
*       Now run some simulations to get predicted thresholds - replicate*;
*     ****************************************************************  *;

estsimp regress threshold threat area trade population ethnic if interwar==1;

setx  area 3 trade mean population mean ethnic mean  threat 0.2;

setx;

simqi;

drop b*;

estsimp regress threshold threat area trade population ethnic if interwar==1;

setx  area 3 trade mean population mean ethnic mean  threat 0.4;

setx;

simqi;

drop b*;

estsimp regress threshold threat area trade population ethnic if interwar==1;

setx area 3 trade mean population mean ethnic mean  threat 0.6;

setx;

simqi;

drop b*;

estsimp regress threshold threat area trade population ethnic if interwar==1;

setx  area 3 trade mean population mean ethnic mean  threat 0.4;

setx;

simqi;

drop b*;

estsimp regress threshold threat area trade population ethnic if interwar==1;

setx  area 3 trade mean population mean ethnic mean  threat 0.8;

setx;

simqi;

drop b*;

estsimp regress threshold threat area trade population ethnic if interwar==1;

setx  area 3 trade mean population mean ethnic mean  threat 1.20;

setx;

simqi;

drop b*;

estsimp regress threshold threat area trade population ethnic if interwar==1;

setx  area 3 trade mean population mean ethnic mean  threat 0.6;

setx;

simqi;

drop b*;

estsimp regress threshold threat area trade population ethnic if interwar==1;

setx  area 3 trade mean population mean ethnic mean  threat 1.20;

setx;

simqi;

drop b*;

estsimp regress threshold threat area trade population ethnic if interwar==1;

setx  area 3 trade mean population mean ethnic mean  threat 1.8;

setx;

simqi;

drop b*;

estsimp regress threshold threat area trade population ethnic if interwar==1;

setx  area 3 trade mean population mean ethnic mean  threat 0.8;

setx;

simqi;

drop b*;

estsimp regress threshold threat area trade population ethnic if interwar==1;

setx  area 3 trade mean population mean ethnic mean  threat 1.6;

setx;

simqi;

drop b*;

estsimp regress threshold threat area trade population ethnic if interwar==1;

setx area 3 trade mean population mean ethnic mean  threat 2.4;

setx;

simqi;

drop b*;

clear;

*     ****************************************************************  *;
*       Now do post 1945 (interwar period)                              *;
*     ****************************************************************  *;

use h:\politicalanalysis\replications\boix\boix.dta;


*     ****************************************************************  *;
*       Model 1                                                         *;
*     ****************************************************************  *;

regress threshold threat area trade population ethnic;

*     ****************************************************************  *;
*       Model 2                                                         *;
*     ****************************************************************  *;

regress threshold threat socialism parties area;

*     ****************************************************************  *;
*       Model 3                                                         *;
*     ****************************************************************  *;

gen area1=10^area;

gen areadummy=.;

replace areadummy=0 if area1>=450;

replace areadummy=1 if area1<450;

gen ethnic_dummy = ethnic*areadummy; 

regress threshold threat ethnic_dummy;




*     ****************************************************************  *;
*     ****************************************************************  *;
*     ****************************************************************  *;
*       Models 1, 2 and 3 when fully specified                          *;
*     ****************************************************************  *;
*     ****************************************************************  *;
*     ****************************************************************  *;

*     ****************************************************************  *;
*       Model 1                                                         *;
*     ****************************************************************  *;

regress threshold threat socialism parties area trade population ethnic;

*     ****************************************************************  *;
*       Model 2 is already fully-specified                              *;
*     ****************************************************************  *;

*     ****************************************************************  *;
*       Model 3                                                         *;
*     ****************************************************************  *;

regress threshold threat socialism parties ethnic areadummy ethnic_dummy;





*     ****************************************************************  *;
*       Does ethnic fragmentation ever have a significant effect?       *;
*     ****************************************************************  *;

regress threshold ethnic areadummy ethnic_dummy threat socialism parties;

matrix b=e(b);
matrix V=e(V);
scalar b1=b[1,1];
scalar b2=b[1,2];
scalar b3=b[1,3];

scalar varb1=V[1,1];
scalar varb2=V[2,2];
scalar varb3=V[3,3];
scalar covb1b3=V[1,3];
scalar covb2b3=V[2,3];

gen conb1=b1+b3*1;

display conb1;

gen conse1=sqrt(varb1+varb3*1^2+2*covb1b3*1);

display conse1;


*     ****************************************************************  *;
*       Does ethnic fragmentation ever have a significant effect? NO    *;
*     ****************************************************************  *;

drop conb1 conse1;



*     ****************************************************************  *;
*       Marginal effect of socialism                                    *;
*     ****************************************************************  *;

set obs 70;

gen threat1=socialism*parties;

regress threshold  socialism parties threat1 area trade population ethnic;


generate JH=((_n-1)/10);    

replace JH=. if _n>60;

*     ****************************************************************  *;
*       Grab elements of the matrix required for calculating            *;
*       conditional coefficients and standard errors.                   *;
*     ****************************************************************  *;

matrix b=e(b);
matrix V=e(V);
scalar b1=b[1,1];
scalar b2=b[1,2];
scalar b3=b[1,3];

scalar varb1=V[1,1];
scalar varb2=V[2,2];
scalar varb3=V[3,3];
scalar covb1b3=V[1,3];
scalar covb2b3=V[2,3];


set more off;

scalar list b1 b2 b3 varb1 varb2 varb3 covb1b3 covb2b3;

*     ****************************************************************  *;
*         Create full range of conditional coefficients for proximity   *;
*     ****************************************************************  *;

gen conb=b1+b3*JH if _n<60;

set more off;

list conb in 1/20;

*     ****************************************************************  *;
*           Create full range of conditional standard errors            *;
*     ****************************************************************  *;

gen conse=sqrt(varb1+varb3*JH^2+2*covb1b3*JH)  if _n<60;
set more off;

*     ****************************************************************  *;
*               Generate confidence intervals at the 95% level          *;
*     ****************************************************************  *;
*     ****************************************************************  *;

gen a=2.074*conse;
gen top=conb+a;
gen bottom=conb-a;
set textsize 100;

*     ****************************************************************  *;
*       Graph the effect of socialism on the electoral threshold        *;
*     ****************************************************************  *;

graph twoway   line conb JH, clwidth(medium) clcolor(blue) clcolor(black)
        ||  line top  JH, clpattern(dash) clwidth(thin) clcolor(black)
        ||  line bottom JH, clpattern(dash) clwidth(thin) clcolor(black)
        ||  ,   
            xlabel(0 1 2 3 4 5 6, labsize(2.5)) 
            ylabel(-1.5 -1 -0.5 0 0.5 1 1.5 2 2.5, labsize(2.5))
            yscale(noline)
            xscale(noline)
            legend(col(1) order(1 2) label(1 "Marginal Effect of Socialist Strength") label(2 "95% Confidence Interval") 
                  label(3 " "))
        yline(0, lcolor(black))  
            title("Marginal Effect of Socialist Strength", size(4))
            subtitle(" " "Dependent Variable: Effective Electoral Threshold" " ", size(3))
            xtitle(Effective Number of Old Parties, size(3)  )
        xsca(titlegap(2))
        ysca(titlegap(2))
            ytitle("Marginal Effect of Socialist Strength", size(3))
        scheme(s2mono) graphregion(fcolor(white));
        
translate @Graph h:\politicalanalysis\replications\boix\socialism1.eps;


*     ****************************************************************  *;
*       Marginal effect of non-socialist parties                        *;
*     ****************************************************************  *;

clear;

use h:\politicalanalysis\replications\boix\boix.dta;

set obs 600;

gen threat1=socialism*parties;

regress threshold  parties socialism threat1 area trade population ethnic;


generate JH=((_n-1)/10);    

replace JH=. if _n>550;

*     ****************************************************************  *;
*       Grab elements of the matrix required for calculating            *;
*       conditional coefficients and standard errors.                   *;
*     ****************************************************************  *;

matrix b=e(b);
matrix V=e(V);
scalar b1=b[1,1];
scalar b2=b[1,2];
scalar b3=b[1,3];

scalar varb1=V[1,1];
scalar varb2=V[2,2];
scalar varb3=V[3,3];
scalar covb1b3=V[1,3];
scalar covb2b3=V[2,3];


set more off;

scalar list b1 b2 b3 varb1 varb2 varb3 covb1b3 covb2b3;

*     ****************************************************************  *;
*         Create full range of conditional coefficients for proximity   *;
*     ****************************************************************  *;

gen conb=b1+b3*JH if _n<550;

set more off;

list conb in 1/20;

*     ****************************************************************  *;
*           Create full range of conditional standard errors            *;
*     ****************************************************************  *;

gen conse=sqrt(varb1+varb3*JH^2+2*covb1b3*JH)  if _n<550;
set more off;

*     ****************************************************************  *;
*               Generate confidence intervals at the 95% level          *;
*     ****************************************************************  *;
*     ****************************************************************  *;

gen a=2.074*conse;
gen top=conb+a;
gen bottom=conb-a;
set textsize 100;

*     ****************************************************************  *;
*       Graph the effect of non-socialist parties on electoral threshold*;
*     ****************************************************************  *;

graph twoway   line conb JH, clwidth(medium) clcolor(blue) clcolor(black)
        ||  line top  JH, clpattern(dash) clwidth(thin) clcolor(black)
        ||  line bottom JH, clpattern(dash) clwidth(thin) clcolor(black)
        ||  ,   
            xlabel(0 10 20 30 40 50 60, labsize(2.5)) 
            ylabel(-25 -20 -15 -10 -5 0 5 10 15 20 , labsize(2.5))
            yscale(noline)
            xscale(noline)
            legend(col(1) order(1 2) label(1 "Marginal Effect of Old Parties") label(2 "95% Confidence Interval") 
                  label(3 " "))
        yline(0, lcolor(black))  
            title("Marginal Effect of the Number of Non-Socialist Parties", size(4))
            subtitle(" " "Dependent Variable: Effective Electoral Threshold" " ", size(3))
            xtitle(Strength of Socialism, size(3)  )
        xsca(titlegap(2))
        ysca(titlegap(2))
            ytitle("Marginal Effect of Old Parties", size(3))
        scheme(s2mono) graphregion(fcolor(white));
        
translate @Graph h:\politicalanalysis\replications\boix\oldparties1.eps;









 exit;
